package com.platform.qujia.service.impl;


import com.platform.qujia.dao.GzhFunctionConfigMapper;
import com.platform.qujia.pojo.GzhFunctionConfig;
import com.platform.qujia.service.GzhFunctionConfigService;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;

import javax.annotation.Resource;
import java.util.List;

/**
 * (GzhFunctionConfig)表服务实现类
 *
 * @author makejava
 * @since 2023-12-05 15:03:56
 */
@Service("gzhFunctionConfigService")
public class GzhFunctionConfigServiceImpl implements GzhFunctionConfigService {
    @Resource
    private GzhFunctionConfigMapper gzhFunctionConfigMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public GzhFunctionConfig queryById(Long id) {
        return this.gzhFunctionConfigMapper.queryById(id);
    }

    /**
     * 分页查询
     *
     * @param gzhFunctionConfig 筛选条件
     * @param pageRequest      分页对象
     * @return 查询结果
     */
    @Override
    public Page<GzhFunctionConfig> queryByPage(GzhFunctionConfig gzhFunctionConfig, PageRequest pageRequest) {
        long total = this.gzhFunctionConfigMapper.count(gzhFunctionConfig);
        return new PageImpl<>(this.gzhFunctionConfigMapper.queryAllByLimit(gzhFunctionConfig, pageRequest), pageRequest, total);
    }

    /**
     * 新增数据
     *
     * @param gzhFunctionConfig 实例对象
     * @return 实例对象
     */
    @Override
    public GzhFunctionConfig insert(GzhFunctionConfig gzhFunctionConfig) {
        this.gzhFunctionConfigMapper.insert(gzhFunctionConfig);
        return gzhFunctionConfig;
    }

    /**
     * 修改数据
     *
     * @param gzhFunctionConfig 实例对象
     * @return 实例对象
     */
    @Override
    public GzhFunctionConfig update(GzhFunctionConfig gzhFunctionConfig) {
        this.gzhFunctionConfigMapper.update(gzhFunctionConfig);
        return this.queryById(gzhFunctionConfig.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.gzhFunctionConfigMapper.deleteById(id) > 0;
    }

    @Override
    public List<GzhFunctionConfig> query(GzhFunctionConfig gzhFunctionConfig) {
        return gzhFunctionConfigMapper.query(gzhFunctionConfig);
    }
}
